package com.longsoft.house.web.controller;

import com.longsoft.house.common.model.User;
import com.longsoft.house.common.result.ResultMsg;
import org.apache.commons.lang3.StringUtils;

public class UserHelper {

    public static ResultMsg validate(User account) {
        if (StringUtils.isBlank(account.getEmail())) {
            return ResultMsg.errorMsg("email有误");
        }
        if (StringUtils.isBlank(account.getName())) {
            return ResultMsg.errorMsg("用户名有误");
        }
        if (StringUtils.isBlank(account.getConfirmPassword()) || StringUtils.isBlank(account.getPassword())
            || !account.getPassword().equals(account.getConfirmPassword())) {
            return ResultMsg.errorMsg("密码与确认密码不一致");
        }
        if (account.getPassword().length() < 6) {
            return ResultMsg.errorMsg("密码大于6位");
        }
        return ResultMsg.successMsg("");
    }
}
